package com.wjl.tableanalyzier.strategy;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class ColumnStrategyRegistry {

    private static final List<ColumnStrategy> strategyList = new CopyOnWriteArrayList<>();

    public static void register(ColumnStrategy strategy) {
        strategyList.add(strategy);
    }


    public static int getSize(String type) {
        for (ColumnStrategy columnStrategy : strategyList) {
            if (columnStrategy.match(type)) {
                return columnStrategy.getSize(type);
            }
        }
        throw new RuntimeException("unknown type");
    }

}
